Public Class clsCajaGeneralSD
    Inherits clsBaseDatos

#Region "Consultas de Datos (Combox)"
    Public Function FormasPago() As DataSet

        Try
            FormasPago = MyBase.TraerDataSet("Select * From FormasDePago Where cClasificador='C' And cIdioma='" & Idioma & "' Order by nOrden")
        Catch ex As Exception
            MessageBox.Show(ex.Message, cMsg.Mensaje("MsgCritico"), MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End Try
    End Function
#End Region

#Region "Carga Cajas y Verifica aperturas"
    Public Function Caja() As DataSet
        Try
            Caja = MyBase.TraerDataSet("SELECT Catalogo.nIdCatalogo, Catalogo.cDescripcion, Catalogo.cIdioma, Catalogo.cStatus FROM Catalogo WHERE Catalogo.cStatus='C' AND Catalogo.nIdentificador=1 And cIdioma='" & Idioma.Trim & "' ORDER BY Catalogo.nOrden")
        Catch ex As Exception
            MessageBox.Show(ex.Message, cMsg.Mensaje("MsgCritico"), MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End Try
    End Function

    Function VerificaCaja() As DataSet
        Dim ds As DataSet
        Dim dr As DataRow
        Dim strSql As String

        strSql = "Select * From CajaMovimiento Where nIdEmpleado=" & intUsuario & " And cStatus='A'"
        Return MyBase.TraerDataSet(strSql)
    End Function
#End Region

#Region "Extrae un Valor Maximo"
    Function ExtraeMaximo(ByVal strSql As String, ByVal bIncrementar As Boolean) As Long
        Dim ds As DataSet, dr As DataRow
        ds = MyBase.TraerDataSet(strSql)
        dr = ds.Tables(0).Rows(0)

        If ds.Tables(0).Rows.Count > 0 Then
            If bIncrementar Then
                If dr.IsNull("IdMaximo") = False Then
                    ExtraeMaximo = dr("IdMaximo") + 1
                Else
                    ExtraeMaximo = 1
                End If
            Else
                If dr.IsNull("IdMaximo") = False Then
                    ExtraeMaximo = dr("IdMaximo")
                Else
                    ExtraeMaximo = 1
                End If
            End If
        Else
            ExtraeMaximo = 1
        End If
    End Function
#End Region

#Region "Carga Encabezados"
    Function CargaEncabezados(ByVal strTabla As String) As DataSet
        Dim strSql As String

        strSql = "Select * From DescripcionCampos Where cFuenteDatos='" & strTabla.Trim & "' Order by nOrden"
        CargaEncabezados = MyBase.TraerDataSet(strSql)

    End Function
#End Region

#Region "Regresa Llave de un comboBox o ListBox etc."
    Function RegresaLlaveSD(ByVal strCampo As String, _
                            ByVal strCampoLlave As String, _
                            ByVal strDescripcion As String, _
                            ByVal strTabla As String, _
                            ByVal bIdioma As Boolean) As Long

        Dim strSql As String
        Dim ds As DataSet
        Dim dr As DataRow

        If bIdioma Then
            ds = MyBase.TraerDataSet("Select *  From " & strTabla & " Where " & strCampo & " ='" & strDescripcion & "' And cIdioma='" & Idioma.Trim & "'")
        Else
            ds = MyBase.TraerDataSet("Select *  From " & strTabla & " Where " & strCampo & " ='" & strDescripcion & "'")
        End If
        If ds.Tables(0).Rows.Count > 0 Then
            dr = ds.Tables(0).Rows(0)
            If dr.IsNull(strCampoLlave) = False Then
                RegresaLlaveSD = dr(strCampoLlave)
            Else
                RegresaLlaveSD = -1
            End If
        Else
            RegresaLlaveSD = -1
        End If
    End Function
#End Region

End Class
